using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_Shared_Question
    {
        public static bool Insert(Object tmp)
        {
            SHARED_QUESTION obj = (SHARED_QUESTION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@QUESTION_ID", obj.QUESTION_ID));
            _list.Add(new SqlParameter("@SHARED_QUESTION_ID", obj.SHARED_QUESTION_ID));
            _list.Add(new SqlParameter("@SHARED_QUESTION_MODIFIABLE", obj.SHARED_QUESTION_MODIFIABLE));
            _list.Add(new SqlParameter("@SHARED_QUESTION_RESHARABLE", obj.SHARED_QUESTION_RESHARABLE));
            _list.Add(new SqlParameter("@SHARED_QUESTION_VIEWABLE", obj.SHARED_QUESTION_VIEWABLE));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));

            int n = clsDataAccessHelper.ExecNonQuery("sp_shared_question_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            SHARED_QUESTION obj = (SHARED_QUESTION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@QUESTION_ID", obj.QUESTION_ID));
            _list.Add(new SqlParameter("@SHARED_QUESTION_ID", obj.SHARED_QUESTION_ID));
            _list.Add(new SqlParameter("@SHARED_QUESTION_MODIFIABLE", obj.SHARED_QUESTION_MODIFIABLE));
            _list.Add(new SqlParameter("@SHARED_QUESTION_RESHARABLE", obj.SHARED_QUESTION_RESHARABLE));
            _list.Add(new SqlParameter("@SHARED_QUESTION_VIEWABLE", obj.SHARED_QUESTION_VIEWABLE));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));

            int n = clsDataAccessHelper.ExecNonQuery("sp_shared_question_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            SHARED_QUESTION obj = (SHARED_QUESTION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            //_list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            //_list.Add(new SqlParameter("@QUESTION_ID", obj.QUESTION_ID));
            _list.Add(new SqlParameter("@SHARED_QUESTION_ID", obj.SHARED_QUESTION_ID));
            //_list.Add(new SqlParameter("@SHARED_QUESTION_MODIFIABLE", obj.SHARED_QUESTION_MODIFIABLE));
            //_list.Add(new SqlParameter("@SHARED_QUESTION_RESHARABLE", obj.SHARED_QUESTION_RESHARABLE));
            //_list.Add(new SqlParameter("@SHARED_QUESTION_VIEWABLE", obj.SHARED_QUESTION_VIEWABLE));
            //_list.Add(new SqlParameter("@USER_ID", obj.USER_ID));

            int n = clsDataAccessHelper.ExecNonQuery("sp_shared_question_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<SHARED_QUESTION> LoadAll()
        {
            List<SHARED_QUESTION> _list = new List<SHARED_QUESTION>();
            //call stored getlist here
            return _list;
        }
    }
}
